<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>

    <script>
        //去重
        let arr = [10, 20, 30, 99, 59, 30, 10, 99, 10]
        //一 set()
        /*   let newArr = [...new Set(arr)]
          console.log(newArr) */

        //二 Array.from()
        /*  let newVal = Array.from(new Set(arr), (val, index) => {
             console.log(index, val)
             return val
         })
         // let newVal = Array.from(new Set(arr))
         console.log(newVal)
 
         var lis = document.getElementsByTagName('li');
         let getLis = Array.from(lis)
         getLis.push('<li>add</li>')
         console.log(getLis) */

        //三 reduce
        /* let newArr = arr.reduce((preVal, curVal, curIndex) => {
            if (preVal.indexOf(curVal) === -1) preVal.push(curVal)
            return preVal
        }, [])
        */

        /* let newArr = arr.reduce((preVal, curVal, curIndex) => {
            if (!preVal.includes(curVal)) preVal.push(curVal)
            return preVal
        }, []) */

        let newArr = arr.reduce((preVal, curVal, curIndex) => preVal.includes(curVal) ? preVal : [...preVal, curVal], [])

        console.log(newArr)
    </script>
</body>

</html>